import * as local from './lib/local.js'
import * as utils from './lib/utils.js'
import * as crypto from './lib/crypto.js'
import * as fileUtils from './lib/files.js'
import * as wxUtils from './lib/wxUtil.js'
import { Base64 as base64 } from './lib/base64.js'

import { checkLogin } from './lib/loginInfo.js'

const { setLocalStorage, getLocalStorage, setToken, getToken, removeToken } = local

const {
    // 展示 toast
    showMessage,
    stopBubble,
    stopDefault,
    truncateString,
    stripHtml,
    getTypeof,
    debounce,
    cloneUtil,
    wait
} = utils

const { encryptDes, decryptDes } = crypto

const { getBase64ImageByUrl } = fileUtils

const { checkHosId, getAppSct, checkAppSct, outLogin } = wxUtils

export { isDateValid, dayDif, dayOfYear, timeFromDate } from './lib/date'
export { joinQuery } from './lib/browser'

const wxUtil = require('./lib/wxUtil');
const uUtils = require('./lib/uUtils')

const modulesFiles = require.context('./lib', true, /\.js$/);

const modules = modulesFiles.keys().reduce((modules, modulePath) => {
    const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
    const value = modulesFiles(modulePath)
    modules[moduleName] = value
    return modules
}, {})

export default modules;
export {
    base64,
    uUtils,
    wxUtil,
    local,
    setLocalStorage,
    getLocalStorage,
    setToken,
    getToken,
    removeToken,
    // 检查是否登录
    checkLogin,
    utils,
    cloneUtil,
    debounce,
    showMessage,
    stopBubble,
    stopDefault,
    truncateString,
    stripHtml,
    getTypeof,
    fileUtils,
    getBase64ImageByUrl,
    wait,
    // 加解密
    crypto,
    encryptDes,
    decryptDes,
    checkHosId,
    getAppSct,
    checkAppSct,
    outLogin,
}